package com.lecture.springlecture.controller;

import com.lecture.springlecture.config.MyClient;
import com.lecture.springlecture.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class HelloController {

    @Autowired
    private MyClient myClient;


    @GetMapping("hello")
    public String hello(MultipartFile multipartFile) {
        System.out.println("文件名：" + multipartFile.getOriginalFilename());
        System.out.println("调用hello接口");
        return "hello";
    }

    @GetMapping("helloTest")
    public void helloTest(MultipartFile multipartFile) {
        System.out.println("开始----------------");
        String s = myClient.helloForest("http://localhost:8081",multipartFile,onProgress -> {

        });
        System.out.println("收到结果：" + s);
        System.out.println("结束----------------");
    }

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.setDisallowedFields("icon");
    }
    @PostMapping("saveUser")
    public void saveUser(User user) {

    }
}
